﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace PongGame
{
    class Ball
    {
        /// <summary>
        /// X co-ordinate
        /// </summary>
        private int X;
        /// <summary>
        /// Y co-ordinate
        /// </summary>
        private int Y;
        /// <summary>
        /// How far across the ball travels each tick
        /// </summary>
        private int Across;
        /// <summary>
        /// How far verticaly the ball travels each tick
        /// </summary>
        private int Vertical;
        private Bat Leftbat;
        private Bat Rightbat;

        public Ball(int Xco,int Yco,Bat RightBat,Bat LeftBat)
        {
            X = Xco;
            Y = Yco;
            Across = 0;
            Vertical = 5;
            this.Leftbat = LeftBat;
            this.Rightbat = RightBat;
        }

        /// <summary>
        /// Move ball based on Across and Vertical Variables
        /// </summary>
        public void Update()
        {
            Y += Vertical;
            X += Across;
            if (Y >= 600-50) Vertical = -Vertical ;
            if (Y <= 0) Vertical = -Vertical;
        }

        /// <summary>
        /// Draw the Ball
        /// </summary>
        public void Draw(SpriteBatch Screen,Texture2D Sprite)
        {
            Vector2 coordinates = new Vector2(X, Y);
            Screen.Draw(Sprite, coordinates, Color.White);
        }
    }
}
